﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using XNAProjectLibrary;

namespace XNAProject
{
    public sealed class CreditsState : BaseGameState, ICreditsState
    {
        private SpriteFont font;

        public CreditsState(Game game)
            : base(game)
        {
            game.Services.AddService(typeof(ICreditsState), this);                                      //add creditstate as service
        }                                                                                               //not sure why
        public override void Update(GameTime gameTime)
        {
            if (Input.WasPressed(0, Buttons.Start, Keys.Escape)                                         //input handling
                || Input.WasPressed(0, Buttons.Start, Keys.Enter)
                || Input.WasPressed(0, Buttons.Start, Keys.Space))
            {
                GameManager.ChangeState(OurGame.StartMenuState.Value);                                  //change to startmenu
            }

            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            OurGame.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);

            OurGame.spriteBatch.DrawString(font, "CreditsState \n press Esc or Enter or Space for StartMenuState", new Vector2(20, 20), Color.White);

            OurGame.spriteBatch.End();                                                                  //simple text draw

            base.Draw(gameTime);
        }

        protected override void LoadContent()
        {
            font = Content.Load<SpriteFont>(@"Fonts\description");                                      //load font
            base.LoadContent();
        }
    }
}
